<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/component/commonTagLib.jsp" %>

<!DOCTYPE html>
<html>
<head>
    <title><spring:message code="message.basic"/></title>
    <%@ include file="/WEB-INF/component/commonCSS.jsp" %>
    <link href="${ctx}/lib/plugins/zTree_v3/css/zTreeStyle/zTreeStyle.css" rel="stylesheet" />
    <style type="text/css">
    	div.box-body {
    		margin-top:7px;
    	}
    </style>
</head>
<body class="skin-blue sidebar-mini fixed skin-blue-light-frame">
    <section class="content-header">
        <h1><spring:message code="message.basic"/></h1>
        <ol class="breadcrumb">
            <li><a href="${ctx}/home.jsp"><i class="fa fa-home"></i><spring:message code="message.lable.first" /></a></li>
            <li class="active"><a href="#"><spring:message code="message.basic"/></a></li>
        </ol>
    </section>
    <section class="content">
        <form id="form" class="form-horizontal" action="${ctx}/sysUser/saveZUserInfo.html" method="post">
	        <input type="hidden" name="id" value="${sysUser.id}" />
	        <input type="hidden" name="type" value="${sysUser.type}" />
            <div class=" box box-success ">
                <div class="box-body">
                    <div class="form-group form-group-xs">
                        <label for="username" class="col-sm-2 text-right"><spring:message code="message.lable.userzhanghaoSpacing"/><spring:message code="message.yanZheng.maoHao"/></label>
                        <div class="col-sm-3 text-left">
                          ${sysUser.username}
                        </div>
                        <label for="roleId" class="col-sm-2 text-right"><spring:message code="message.lable.userjueseSpacing" /><spring:message code="message.yanZheng.maoHao"/></label>
                        <div class="col-sm-3 text-left">
                       	 ${sysUser.typeName}
                        </div>
                    </div>
                    
                    <div class="form-group form-group-xs">
                    <c:if test="${sysUser.main == 1}">
                      <label for="name" class="col-sm-2 text-right"><spring:message code="message.lable.username" /><spring:message code="message.yanZheng.maoHao"/></label>
                        <div class="col-sm-3 text-left">
                            <input name="name" value="${sysUser.name}" type="hidden" />
                            <input class="form-control" id="name" name="name" disabled="disabled" value="${sysUser.name}" type="text" maxlength="50" >
                        </div>
                    </c:if>
                    <c:if test="${sysUser.main == 0}">
                      <label for="name" class="col-sm-2 text-right"><spring:message code="message.lable.username" /><spring:message code="message.yanZheng.maoHao"/></label>
                        <div class="col-sm-3 text-left">
                            <input class="form-control" id="name" name="name" value="${sysUser.name}" type="text" maxlength="50" >
                        </div>
                    </c:if>
                        <label for="email" class="col-sm-2 text-right"><spring:message code="message.lable.useremailSpacing" /><spring:message code="message.yanZheng.maoHao"/></label>
                        <div class="col-sm-3 text-left">
                            <input class="form-control" id="email" name="email" value="${sysUser.email}" placeholder="<spring:message code="message.lable.useremailSpacing" />" type="text" maxlength="25">
                        </div>
                    </div >
                    <div class="form-group form-group-xs">
                     
                        <label for="phone" class="col-sm-2 text-right"><spring:message code="message.lable.phoneSpacing" /><spring:message code="message.yanZheng.maoHao"/></label>
                        <div class="col-sm-3 text-left">
                            <input class="form-control" id="phone" name="phone" value="${sysUser.phone}" placeholder="<spring:message code="message.lable.phoneSpacing" />" type="text" maxlength="25">
                        </div>
                    </div>
                    <div class="form-group form-group-xs">
                        <label for="remark" class="col-sm-2 control-label"><spring:message code="message.lable.remarkSpacing"/><spring:message code="message.yanZheng.maoHao"/></label>
                        <div class="col-sm-8">
                            <textarea class="form-control" id="remark" name="remark" rows="3" placeholder="<spring:message code="message.lable.remarkSpacing"/>" maxlength="500">${sysUser.remark}</textarea>
                        </div>
                    </div>
                </div>
                <div class="box-footer text-center">
                    <ms:btn url="/sysUser/saveZUserInfo.html"><button type="button" class="btn btn-success btn-sm" onclick="zxSaveRole();"><spring:message code="message.button.saveSpacing" /></button></ms:btn>
                </div>
            </div>
        </form>
    </section>
    
    <%@ include file="/WEB-INF/component/commonJS.jsp" %>
    <script src="${ctx}/lib/plugins/zTree_v3/js/jquery.ztree.all-3.5.min.js"></script>
    
    <script type="text/javascript">
    $(function(){
    	$("form#form :input").change(function(){
    		$("form#form").data("changed",true);
    	})
    });
        //  保存用户信息
        function zxSaveRole() {
            if (!validate()) {
                return;
            }
            $.HN.message.confirm("<spring:message code='message.HN.alert.OkSaveYESorNO'/>", "", "").on(function(e) {
                if (e) {
                    $("#form").ajaxSubmit({
                        dataType : "json",
                        timeout: 10000,
                        success : function(result, statusText) {
                            if (result.success) {
                            	   $.alert("<spring:message code='message.HN.alert.success'/>","success");
                            	   // setTimeout("count()", 500) 
                            } else {
                            	top.$.HN.message.alert(result.msg || "<spring:message code='message.HN.alert.fail'/>", "","error");
                            }
                        }
                    });
                }
            });
            
            
            
        }
        function count(){
        	 top.location = "${ctx}/login.html";
        }
    	//	校验用户信息
    	function validate() {
			if(!$("form#form").data("changed")){
				top.$.HN.message.alert("<spring:message code='message.lable.noModify'/>", "", "warn");
    			return false;  		
        	}
    		
    		var name = $.trim($("#name").val());
    		if (name == null || name == "") {
    			top.$.HN.message.alert("<spring:message code='message.lable.text'/><spring:message code='message.HN.alert.input'/><spring:message code='message.lable.username'/><spring:message code="message.yanZheng.ganTanHao"/>", "<spring:message code='message.HN.alert.type'/>", "warn");
    			$("#name").focus();
    			return false;
    		}
    		
    		var email = $.trim($("#email").val());
    		if (email.replace(/(^s*)|(s*$)/g, "").length !=0) {
    			 var a =/[\w!#$%&'*+/=?^_`{|}~-]+(?:\.[\w!#$%&'*+/=?^_`{|}~-]+)*@(?:[\w](?:[\w-]*[\w])?\.)+[\w](?:[\w-]*[\w])?/;
    			if(!a.test(email)){
    				top.$.HN.message.alert("<spring:message code='message.lable.useremail'/><spring:message code='message.HN.alert.gsbzq'/><spring:message code="message.yanZheng.ganTanHao"/>", "<spring:message code='message.HN.alert.type'/>", "warn");
		        	$("#email").focus();
	    			return false;
		   		 }
    		}
    		var phone = $.trim($("#phone").val());
    		if (phone.replace(/(^s*)|(s*$)/g, "").length !=0) {
    			var b=/((15)\d{9})|((13)\d{9})|((18)\d{9})|(0[1-9]{2,3}\-?[1-9]{6,7})/i;  
    			if(!b.test(phone)){
    				top.$.HN.message.alert("<spring:message code='message.lable.phone'/><spring:message code='message.HN.alert.gsbzq'/>", "<spring:message code='message.HN.alert.type'/>", "warn");
    		        	$("#phone").focus();
    	    			return false;
    		    }
    		}
    		return true;
    	}
    </script>
    
</body>
</html>
